﻿namespace WMS6.Services
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.ServiceModel;
    using System.ServiceModel.Activation;
    using WMS6.BLL;
    using WMS6.Common;
    using WMS6.DataEntity;
    using WMS6.QueryEntity;

    [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall), AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
    public class StockCountService : IStockCountService
    {
        public string AdjustInventoryQtyForPc(string PhysicalRequestId, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new PhysicalRequestBLL(pubParasInfo).AdjustInventoryQtyForPc(PhysicalRequestId);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return temp;
        }

        public string CycleCountRelease(CycleCountCriteriaInfo cycleCountCriteriaInfo, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new CycleCountCriteriaBLL(pubParasInfo).CycleCountRelease(cycleCountCriteriaInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return temp;
        }

        public string DeleteCycleCountRelease(List<string> IDS, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new CycleCountReleaseBLL(pubParasInfo).DeleteCycleCountRelease(IDS);
                new OperationLogBLL(pubParasInfo).Insert("StockCountService_DeleteCycleCountRelease", IDS, pubParasInfo);
                return lineID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return lineID;
        }

        public string DeleteCycleCountRequest(List<string> IDS, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new CycleCountRequestBLL(pubParasInfo).DeleteCycleCountRequest(IDS);
                new OperationLogBLL(pubParasInfo).Insert("StockCountService_DeleteCycleCountRequest", IDS, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return lineID;
        }

        public string DeleteCycleCountTag(string releaseID, List<string> TagNo, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new CycleCountTagBLL(pubParasInfo).DeleteCycleCountTag(releaseID, TagNo);
                new OperationLogBLL(pubParasInfo).Insert("StockCountService_DeleteCycleCountTag", releaseID, TagNo, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return temp;
        }

        public string DeletePhysicalRequest(List<string> ordersID, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new PhysicalRequestBLL(pubParasInfo).DeletePhysicalRequest(ordersID);
                new OperationLogBLL(pubParasInfo).Insert("StockCountService_DeletePhysicalRequest", ordersID, pubParasInfo);
                return lineID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return lineID;
        }

        public string DeletePhysicalTag(List<string> IDS, List<string> TagNo, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new PhysicalTagBLL(pubParasInfo).DeletePhysicalTag(IDS, TagNo);
                new OperationLogBLL(pubParasInfo).Insert("StockCountService_DeletePhysicalTag", IDS, TagNo, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return lineID;
        }

        public DataSet GetAllCycleCountRelease(PubParasInfo pubParasInfo)
        {
            CycleCountReleaseBLL cycleCountReleaseBLL = new CycleCountReleaseBLL(pubParasInfo);
            return cycleCountReleaseBLL.GetAllCycleCountRelease();
        }

        public DataSet GetAllCycleCountRequest(PubParasInfo pubParasInfo)
        {
            CycleCountRequestBLL cycleCountRequestBLL = new CycleCountRequestBLL(pubParasInfo);
            return cycleCountRequestBLL.GetAllCycleCountRequest();
        }

        public DataSet GetAllPhysicalRequest(PubParasInfo pubParasInfo)
        {
            PhysicalRequestBLL physicalRequestBLL = new PhysicalRequestBLL(pubParasInfo);
            return physicalRequestBLL.GetAllPhysicalRequest();
        }

        public DataSet GetAllPhysicalTag(PubParasInfo pubParasInfo)
        {
            PhysicalTagBLL physicalTagBLL = new PhysicalTagBLL(pubParasInfo);
            return physicalTagBLL.GetAllPhysicalTag();
        }

        public DataSet GetCycleCountReleaseByQueryEntity(CycleCountReleaseQueryEntity cycleCountReleaseQuery, PubParasInfo pubParasInfo)
        {
            CycleCountReleaseBLL cycleCountReleaseBLL = new CycleCountReleaseBLL(pubParasInfo);
            return cycleCountReleaseBLL.GetCycleCountReleaseByQueryEntity(cycleCountReleaseQuery);
        }

        public CycleCountReleaseInfo GetCycleCountReleaseInfoByID(string ReleaseID, PubParasInfo pubParasInfo)
        {
            CycleCountReleaseInfo cycleCountReleaseInfo = null;
            try
            {
                cycleCountReleaseInfo = new CycleCountReleaseBLL(pubParasInfo).GetCycleCountReleaseInfoByID(ReleaseID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return cycleCountReleaseInfo;
        }

        public DataSet GetCycleCountRequestByQueryEntity(CycleCountRequestQueryEntity RequestEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                CycleCountRequestBLL cycleCountRequestBLL = new CycleCountRequestBLL(pubParasInfo);
                return cycleCountRequestBLL.GetCycleCountRequestByQueryEntity(RequestEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return null;
        }

        public CycleCountRequestInfo GetCycleCountRequestInfoByID(string RequestID, PubParasInfo pubParasInfo)
        {
            CycleCountRequestInfo CycleCountRequest = new CycleCountRequestInfo();
            try
            {
                CycleCountRequest = new CycleCountRequestBLL(pubParasInfo).GetCycleCountRequestInfoByID(RequestID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return CycleCountRequest;
        }

        public CycleCountTagInfo GetCycleCountTagByID(string ReleaseID, string TagNo, PubParasInfo pubParasInfo)
        {
            CycleCountTagInfo cycleCountTagInfo = new CycleCountTagInfo();
            try
            {
                cycleCountTagInfo = new CycleCountTagBLL(pubParasInfo).GetCycleCountTagByID(ReleaseID, TagNo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return cycleCountTagInfo;
        }

        public PhysicalRequestInfo GetPCReviewInfoByID(string RequestInfoByID, PubParasInfo pubParasInfo)
        {
            PhysicalRequestInfo PhysicalRequest = new PhysicalRequestInfo();
            try
            {
                PhysicalRequestBLL physicalRequestBLL = new PhysicalRequestBLL(pubParasInfo);
                return physicalRequestBLL.GetPCReviewInfoByID(RequestInfoByID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return PhysicalRequest;
        }

        public DataSet GetPhysicalRequestDAByQueryEntity(PhysicalRequestQueryEntity RequestEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                PhysicalRequestBLL physicalRequestBLL = new PhysicalRequestBLL(pubParasInfo);
                return physicalRequestBLL.GetPhysicalRequestDAByQueryEntity(RequestEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return null;
        }

        public PhysicalRequestInfo GetPhysicalRequestInfoByID(string RequestInfoByID, PubParasInfo pubParasInfo)
        {
            PhysicalRequestInfo PhysicalRequest = new PhysicalRequestInfo();
            try
            {
                PhysicalRequestBLL physicalRequestBLL = new PhysicalRequestBLL(pubParasInfo);
                return physicalRequestBLL.GetPhysicalRequestInfoByID(RequestInfoByID);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return PhysicalRequest;
        }

        public DataSet GetPhysicalTagDAByQueryEntity(PhysicalTagQueryEntity RequestEntity, PubParasInfo pubParasInfo)
        {
            try
            {
                PhysicalTagBLL physicalTagBLL = new PhysicalTagBLL(pubParasInfo);
                return physicalTagBLL.GetPhysicalTagByQueryEntity(RequestEntity);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return null;
        }

        public PhysicalTagInfo GetPhysicalTagInfoByID(string id, int TagNo, PubParasInfo pubParasInfo)
        {
            PhysicalTagInfo PhysicalTag = new PhysicalTagInfo();
            try
            {
                PhysicalTagBLL physicalTagBLL = new PhysicalTagBLL(pubParasInfo);
                return physicalTagBLL.GetPhysicalTagInfoByID(id, TagNo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return PhysicalTag;
        }

        public List<string> GetPhysicalTagNoListByID(string physicaltagID, PubParasInfo pubParasInfo)
        {
            PhysicalTagBLL physicalTagBLL = new PhysicalTagBLL(pubParasInfo);
            return physicalTagBLL.GetPhysicalTagNoListByID(physicaltagID);
        }

        public string InsertCycleCountRelease(CycleCountReleaseInfo cycleCountReleaseInfo, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new CycleCountReleaseBLL(pubParasInfo).InsertCycleCountRelease(cycleCountReleaseInfo);
                new OperationLogBLL(pubParasInfo).Insert("StockCountService_InsertCycleCountRelease", cycleCountReleaseInfo, pubParasInfo);
                return lineID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return lineID;
        }

        public string InsertCycleCountRequest(CycleCountRequestInfo CycleCountRequestInfo, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new CycleCountRequestBLL(pubParasInfo).InsertCycleCountRequest(CycleCountRequestInfo);
                new OperationLogBLL(pubParasInfo).Insert("StockCountService_InsertCycleCountRequest", CycleCountRequestInfo, pubParasInfo);
                return lineID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return lineID;
        }

        public string InsertPhysicalRequest(PhysicalRequestInfo physicalRequestInfo, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new PhysicalRequestBLL(pubParasInfo).InsertPhysicalRequest(physicalRequestInfo);
                new OperationLogBLL(pubParasInfo).Insert("StockCountService_InsertPhysicalRequest", physicalRequestInfo, pubParasInfo);
                return lineID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return lineID;
        }

        public string InsertPhysicalTag(PhysicalTagInfo obj, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new PhysicalTagBLL(pubParasInfo).InsertPhysicalTag(obj);
                new OperationLogBLL(pubParasInfo).Insert("StockCountService_InsertPhysicalTag", obj, pubParasInfo);
                return lineID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return lineID;
        }

        public string InvHoldForPC(string id, string strType, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new PhysicalRequestBLL(pubParasInfo).InvHoldForPC(id, strType);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return temp;
        }

        public string SetCycleCountCriteria(CycleCountCriteriaInfo cycleCountCriteriaInfo, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new CycleCountCriteriaBLL(pubParasInfo).SetCycleCountCriteria(cycleCountCriteriaInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return temp;
        }

        public string UpdateCycleCountRelease(CycleCountReleaseInfo cycleCountReleaseInfo, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new CycleCountReleaseBLL(pubParasInfo).UpdateCycleCountRelease(cycleCountReleaseInfo);
                new OperationLogBLL(pubParasInfo).Insert("StockCountService_UpdateCycleCountRelease", cycleCountReleaseInfo, pubParasInfo);
                return lineID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return lineID;
        }

        public string UpdateCycleCountRequest(CycleCountRequestInfo CycleCountRequestInfo, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new CycleCountRequestBLL(pubParasInfo).UpdateCycleCountRequest(CycleCountRequestInfo);
                new OperationLogBLL(pubParasInfo).Insert("StockCountService_UpdateCycleCountRequest", CycleCountRequestInfo, pubParasInfo);
                return lineID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return lineID;
        }

        public string UpdateCycleCountTag(List<CycleCountTagInfo> obj, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new CycleCountTagBLL(pubParasInfo).UpdateCycleCountTag(obj);
                new OperationLogBLL(pubParasInfo).Insert("StockCountService_UpdateCycleCountTag", obj, pubParasInfo);
                return lineID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return lineID;
        }

        public string UpdatePhysicalRequest(PhysicalRequestInfo physicalRequestInfo, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new PhysicalRequestBLL(pubParasInfo).UpdatePhysicalRequest(physicalRequestInfo);
                new OperationLogBLL(pubParasInfo).Insert("StockCountService_UpdatePhysicalRequest", physicalRequestInfo, pubParasInfo);
                return lineID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return lineID;
        }

        public string UpdatePhysicalTag(PhysicalTagInfo obj, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new PhysicalTagBLL(pubParasInfo).UpdatePhysicalTag(obj);
                new OperationLogBLL(pubParasInfo).Insert("StockCountService_UpdatePhysicalTag", obj, pubParasInfo);
                return lineID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return lineID;
        }

        public string UpdatePhysicalTagList(List<PhysicalTagInfo> obj, string CountType, PubParasInfo pubParasInfo)
        {
            string lineID = string.Empty;
            try
            {
                lineID = new PhysicalTagBLL(pubParasInfo).UpdatePhysicalTagList(obj, CountType);
                new OperationLogBLL(pubParasInfo).Insert("StockCountService_UpdatePhysicalTag", obj, pubParasInfo);
                return lineID;
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return lineID;
        }

        public string UpdateTagQtyByReleaseIDAndTagNo(CycleCountTagInfo cycleCountTag, PubParasInfo pubParasInfo)
        {
            string temp = string.Empty;
            try
            {
                temp = new CycleCountTagBLL(pubParasInfo).UpdateTagQtyByReleaseIDAndTagNo(cycleCountTag);
                new OperationLogBLL(pubParasInfo).Insert("StockCountService_UpdateTagQtyByReleaseIDAndTagNo", cycleCountTag, pubParasInfo);
            }
            catch (Exception ex)
            {
                CommonErrorHandler.ErrorTypeExchange(ex, "SotckCiuntService异常");
            }
            return temp;
        }
    }
}

